package com.mall4j.cloud.order.interfaces;

import com.mall4j.cloud.base.model.BasePageVo;
import com.mall4j.cloud.base.model.BaseResult;
import com.mall4j.cloud.order.application.cmd.CreateOrderCmd;
import com.mall4j.cloud.order.application.model.qo.OrderQo;
import com.mall4j.cloud.order.application.query.OrderQueryService;
import com.mall4j.cloud.order.application.service.OrderAppService;
import com.mall4j.cloud.order.application.model.vo.OrderVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.apache.ibatis.annotations.Delete;
import org.springframework.web.bind.annotation.*;

@Tag(name = "订单服务", description = "C端订单服务")
@RequestMapping("/order")
@RestController
public class OrderController {

    @Resource
    OrderAppService orderAppService;

    @Resource
    OrderQueryService orderQueryService;

    @Operation(summary = "订单列表", description = "订单列表")
    @GetMapping("/orders")
    public BaseResult<BasePageVo<OrderVo>> list(OrderQo orderQo) {
        BasePageVo<OrderVo> result = orderQueryService.list(orderQo);
        return BaseResult.success(result);
    }


    @Operation(summary = "订单详情", description = "用户下单")
    @PostMapping("/orders/{orderId}")
    public BaseResult<String> detail(@PathVariable("orderId") String orderId) {
        return BaseResult.success("ok");
    }


    @Operation(summary = "普通下单提交", description = "用户下单")
    @PostMapping("/orders")
    public BaseResult<String> submitOrder(@RequestBody CreateOrderCmd createOrderCmd) {
        orderAppService.submitOrder(createOrderCmd);
        return BaseResult.success("ok");
    }

    @Operation(summary = "购物车下单提交", description = "用户下单")
    @PostMapping("/orders/carts")
    public BaseResult<String> submitCarOrder() {
        return BaseResult.success("ok");
    }

    @Operation(summary = "获取已支付订单信息", description = "用户下单")
    @PostMapping("/payOrderInfo/{orderId}")
    public BaseResult<String> payOrderInfo(@PathVariable("orderId") String orderId) {
        return BaseResult.success("ok");
    }


    @Operation(summary = "取消订单", description = "用户下单")
    @PostMapping("/orders/{orderId}/cancel")
    public BaseResult<String> cancelOrder(@PathVariable("orderId") String orderId) {
        return BaseResult.success("ok");
    }

    @Operation(summary = "确认收货", description = "用户下单")
    @PostMapping("/orders/{orderId}/confirm")
    public BaseResult<String> receiveOrder(@PathVariable("orderId") String orderId) {
        return BaseResult.success("ok");
    }

    @Operation(summary = "删除订单", description = "用户下单")
    @Delete("/orders/{orderId}")
    public BaseResult<String> deleteOrder(@PathVariable("orderId") String orderId) {
        return BaseResult.success("ok");
    }


}
